<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes"/>

<xsl:template name="robinsjexcal-style-and-script">
<style>
  <xsl:for-each select="library/movies/movie[position() mod $nbCols = 1]">
    <xsl:apply-templates select=".|following-sibling::movie[position() &lt; $nbCols]" mode="bigthumbcss">
      <xsl:with-param name="gap" select="(position() - 1) * $nbCols" />
    </xsl:apply-templates>
  </xsl:for-each>

</style>
<title>MovieJukebox</title>
<script>
var alphaim=[ 
  ",",
  ",",
  <xsl:for-each select="library/category[@name='Title']/index">
    "<xsl:value-of select="@name" />,<xsl:value-of select="." />.html",
  </xsl:for-each>
  ",",
  ","
];

var genreim=[
  ",",
  ",",
  <xsl:for-each select="library/category[@name='Other']/index">
    "<xsl:value-of select="@name" />,<xsl:value-of select="." />.html",
  </xsl:for-each>
  <xsl:for-each select="library/category[@name='Genres']/index">
    "<xsl:value-of select="@name" />,<xsl:value-of select="." />.html",
  </xsl:for-each>
  ",",
  ","
];


var alphaid = 2;
var genrecnt = 2;
var flag = 1;

<xsl:choose>
  <xsl:when test="//index[@current='true']/@name = '09'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'A'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'B'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'C'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'D'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'E'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'F'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'G'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'H'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'I'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'J'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'K'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'L'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'M'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'N'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'O'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'P'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'Q'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'R'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'S'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'T'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'U'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'V'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'W'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'X'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'Y'">flag = 0</xsl:when>
  <xsl:when test="//index[@current='true']/@name = 'Z'">flag = 0</xsl:when>
  <xsl:otherwise>flag = 1</xsl:otherwise>
</xsl:choose>

var xon = index<xsl:value-of select="translate(//index[@current='true']/@name,'-&#x20;','_')" />
var yon = 0
var pagenum = 1

var xon = [
  "",
  <xsl:for-each select="library/movies/movie[@isTrailer != 'true']">
    <xsl:choose>
      <xsl:when test="count(files/file) > 1">
        "<xsl:value-of select='baseFilename' />,<xsl:value-of select="baseFilename" />.playlist.jsp",
      </xsl:when>
      <xsl:otherwise>
        "<xsl:value-of select='baseFilename' />,<xsl:value-of select="files/file[1]/fileURL" />",
      </xsl:otherwise>
    </xsl:choose>
  </xsl:for-each>
  ""
];

// moves the letters left and right 
function alphaud(x)
{
  var len = alphaim.length
  var last = len - 2
  var twoItems, prevItems, twoprevItems, nextItems, twonextItems

  if (alphaid+x == last) { alphaid = 2 }
  else if (alphaid+x == 1) { alphaid = last - 1 }
  else { alphaid = alphaid+x }

  twoItems = alphaim[alphaid].split(",")
  prevItems = alphaim[alphaid-1].split(",")
  twoprevItems = alphaim[alphaid-2].split(",")
  nextItems = alphaim[alphaid+1].split(",")
  twonextItems = alphaim[alphaid+2].split(",")

  document.getElementById('twoup').firstChild.nodeValue = twoprevItems[0];
  document.getElementById('twoup').attributes[0].nodeValue = twoprevItems[1];

  document.getElementById('previ').firstChild.nodeValue = prevItems[0];
  document.getElementById('previ').attributes[0].nodeValue = prevItems[1];

  document.getElementById('change').firstChild.nodeValue = twoItems[0];
  document.getElementById('change').attributes[0].nodeValue = twoItems[1];

  document.getElementById('next').firstChild.nodeValue = nextItems[0];
  document.getElementById('next').attributes[0].nodeValue = nextItems[1]; 

  document.getElementById('twodown').firstChild.nodeValue = twonextItems[0];
  document.getElementById('twodown').attributes[0].nodeValue = twonextItems[1];
}

// moves the genres left and right
function genrelist(x)
{
  var glen = genreim.length
  var glast = glen - 2
  var genreItems, prevgenre, nextgenre, twoprevgenre, twonextgenre

  if (genrecnt+x == glast) { genrecnt = 2 }
  else if (genrecnt+x == 1) { genrecnt = glast - 1 }
  else { genrecnt = genrecnt+x }

  genreItems = genreim[genrecnt].split(",")
  prevgenre = genreim[genrecnt-1].split(",")
  nextgenre = genreim[genrecnt+1].split(",")
  twoprevgenre = genreim[genrecnt-2].split(",")
  twonextgenre = genreim[genrecnt+2].split(",")

  document.getElementById('twoup').firstChild.nodeValue = twoprevgenre[0];
  document.getElementById('twoup').attributes[0].nodeValue = twoprevgenre[1];

  document.getElementById('previ').firstChild.nodeValue = prevgenre[0];
  document.getElementById('previ').attributes[0].nodeValue = prevgenre[1];

  document.getElementById('change').firstChild.nodeValue = genreItems[0];
  document.getElementById('change').attributes[0].nodeValue = genreItems[1];

  document.getElementById('next').firstChild.nodeValue = nextgenre[0];
  document.getElementById('next').attributes[0].nodeValue = nextgenre[1]; 

  document.getElementById('twodown').firstChild.nodeValue = twonextgenre[0];
  document.getElementById('twodown').attributes[0].nodeValue = twonextgenre[1];
}

// change the list to letters 
function loadletter()
{
  var twoItems, prevItems, twoprevItems, nextItems, twonextItems

  flag = 0
  alphaid = 2
  twoItems = alphaim[alphaid].split(",")
  prevItems = alphaim[alphaid-1].split(",")
  twoprevItems = alphaim[alphaid-2].split(",")
  nextItems = alphaim[alphaid+1].split(",")
  twonextItems = alphaim[alphaid+2].split(",")

  document.getElementById('twoup').firstChild.nodeValue = twoprevItems[0];
  document.getElementById('twoup').attributes[0].nodeValue = twoprevItems[1];

  document.getElementById('previ').firstChild.nodeValue = prevItems[0];
  document.getElementById('previ').attributes[0].nodeValue = prevItems[1];

  document.getElementById('change').firstChild.nodeValue = twoItems[0];
  document.getElementById('change').attributes[0].nodeValue = twoItems[1];

  document.getElementById('next').firstChild.nodeValue = nextItems[0];
  document.getElementById('next').attributes[0].nodeValue = nextItems[1]; 

  document.getElementById('twodown').firstChild.nodeValue = twonextItems[0];
  document.getElementById('twodown').attributes[0].nodeValue = twonextItems[1]; 
  return false
}

// change the list to genres 
function loadgenre()
{
  var genreItems, prevgenre, nextgenre, twoprevgenre, twonextgenre

  flag = 1
  genrecnt = 2
  genreItems = genreim[genrecnt].split(",")
  prevgenre = genreim[genrecnt-1].split(",")
  nextgenre = genreim[genrecnt+1].split(",")
  twoprevgenre = genreim[genrecnt-2].split(",")
  twonextgenre = genreim[genrecnt+2].split(",")

  document.getElementById('twoup').firstChild.nodeValue = twoprevgenre[0];
  document.getElementById('twoup').attributes[0].nodeValue = twoprevgenre[1];

  document.getElementById('previ').firstChild.nodeValue = prevgenre[0];
  document.getElementById('previ').attributes[0].nodeValue = prevgenre[1];

  document.getElementById('change').firstChild.nodeValue = genreItems[0];
  document.getElementById('change').attributes[0].nodeValue = genreItems[1];

  document.getElementById('next').firstChild.nodeValue = nextgenre[0];
  document.getElementById('next').attributes[0].nodeValue = nextgenre[1]; 

  document.getElementById('twodown').firstChild.nodeValue = twonextgenre[0];
  document.getElementById('twodown').attributes[0].nodeValue = twonextgenre[1];

  return false
}

//
function upDown(x)
{
  if (flag == 0)
    alphaud(x)
  else
    genrelist(x)
  return false
}

//
function findItem( list, item )
{
  var result = -1;

  for ( var i = 0 ; i != list.length ; i++ )
  {
    if (list[i] == item) { return i; }
  }
  return result;
}

//
function initpage()
{
  var inittest = -1

  if (flag == 0)
  {
    inittest = findItem( alphaim,
      <xsl:choose>
        <xsl:when test="//index[@current='true']/@name = '09'">"09,Title_09_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'A'">"A,Title_A_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'B'">"B,Title_B_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'C'">"C,Title_C_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'D'">"D,Title_D_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'E'">"E,Title_E_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'F'">"F,Title_F_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'G'">"G,Title_G_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'H'">"H,Title_H_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'I'">"I,Title_I_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'J'">"J,Title_J_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'K'">"K,Title_K_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'L'">"L,Title_L_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'M'">"M,Title_M_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'N'">"N,Title_N_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'O'">"O,Title_O_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'P'">"P,Title_P_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Q'">"Q,Title_Q_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'R'">"R,Title_R_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'S'">"S,Title_S_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'T'">"T,Title_T_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'U'">"U,Title_U_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'V'">"V,Title_V_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'W'">"W,Title_W_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'X'">"X,Title_X_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Y'">"Y,Title_Y_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Z'">"Z,Title_Z_1.html"</xsl:when>
        <xsl:otherwise>"09,Title_09_1.html"</xsl:otherwise>
      </xsl:choose>
    )

    alphaid = inittest
    var twoItems = alphaim[alphaid].split(",")
    var prevItems = alphaim[alphaid-1].split(",")
    var twoprevItems = alphaim[alphaid-2].split(",")
    var nextItems = alphaim[alphaid+1].split(",")
    var twonextItems = alphaim[alphaid+2].split(",")

    document.getElementById('twoup').firstChild.nodeValue = twoprevItems[0];
    document.getElementById('twoup').attributes[0].nodeValue = twoprevItems[1];

    document.getElementById('previ').firstChild.nodeValue = prevItems[0];
    document.getElementById('previ').attributes[0].nodeValue = prevItems[1];

    document.getElementById('change').firstChild.nodeValue = twoItems[0];
    document.getElementById('change').attributes[0].nodeValue = twoItems[1];

    document.getElementById('next').firstChild.nodeValue = nextItems[0];
    document.getElementById('next').attributes[0].nodeValue = nextItems[1]; 

    document.getElementById('twodown').firstChild.nodeValue = twonextItems[0];
    document.getElementById('twodown').attributes[0].nodeValue = twonextItems[1]; 
  }
  else
  {
    inittest = findItem( genreim,
      <xsl:choose>
        <xsl:when test="//index[@current='true']/@name = 'All'">"All,Other_All_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'HD'">"HD,Other_HD_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'TV Shows'">"TV Shows,Other_TV Shows_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Movies'">"Movies,Other_Movies_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Trailers'">"Trailers,Other_Trailers_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'New'">"New,Other_New_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Action'">"Action,Genres_Action_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Comedy'">"Comedy,Genres_Comedy_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Animation'">"Animation,Genres_Animation_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Documentary'">"Documentary,Genres_Documentary_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Drama'">"Drama,Genres_Drama_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Fantasy'">"Fantasy,Genres_Fantasy_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Other'">"Other,Genres_Other_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Sci-Fi'">"Sci-Fi,Genres_Sci-Fi_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Thriller'">"Thriller,Genres_Thriller_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Reality-TV'">"Reality-TV,Genres_Reality-TV_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Horror'">"Horror,Genres_Horror_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Family'">"Family,Genres_Family_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Music'">"Music,Genres_Music_1.html"</xsl:when>
        <xsl:when test="//index[@current='true']/@name = 'Top250'">"Top250,Other_Top250_1.html"</xsl:when>
        <xsl:otherwise>"All,Other_All_1.html"</xsl:otherwise>
      </xsl:choose>
    )

    genrecnt = inittest
    var genreItems = genreim[genrecnt].split(",")
    var prevgenre = genreim[genrecnt-1].split(",")
    var nextgenre = genreim[genrecnt+1].split(",")
    var twoprevgenre = genreim[genrecnt-2].split(",")
    var twonextgenre = genreim[genrecnt+2].split(",")

    document.getElementById('twoup').firstChild.nodeValue = twoprevgenre[0];
    document.getElementById('twoup').attributes[0].nodeValue = twoprevgenre[1];

    document.getElementById('previ').firstChild.nodeValue = prevgenre[0];
    document.getElementById('previ').attributes[0].nodeValue = prevgenre[1];

    document.getElementById('change').firstChild.nodeValue = genreItems[0];
    document.getElementById('change').attributes[0].nodeValue = genreItems[1];

    document.getElementById('next').firstChild.nodeValue = nextgenre[0];
    document.getElementById('next').attributes[0].nodeValue = nextgenre[1]; 

    document.getElementById('twodown').firstChild.nodeValue = twonextgenre[0];
    document.getElementById('twodown').attributes[0].nodeValue = twonextgenre[1];
  }

  return false
}

</script>
<script type="text/javascript">
//
function togglePopup(x)
{
  var temp = document.styleSheets[0].cssRules[(x)].style
  if (temp.visibility == 'visible')
    temp.visibility = 'hidden'
  else
    temp.visibility = 'visible'
  return false;
}
</script>
<script>
//
function titles(x,y)
{
  var title=[
    <xsl:for-each select="library/movies/movie">
      "<xsl:value-of select="title" />
      <xsl:if test="season &gt; 0"> - Season <xsl:value-of select="season" /></xsl:if>
      <xsl:if test="season = -1 and $showyear = 'true' and year != 'UNKNOWN'">
        <xsl:text> - </xsl:text><xsl:value-of select="year" />
      </xsl:if>
      <xsl:if test="$showrating = 'true' and certification != 'UNKNOWN' and string-length(certification) &gt; 0">
        <xsl:text> (</xsl:text><xsl:value-of select="certification" /><xsl:text>)</xsl:text>
      </xsl:if>"
      <xsl:if test="position() != last()">,</xsl:if>
    </xsl:for-each>
];

  if (y == 'visible') {
    document.getElementById('movieTitles').firstChild.nodeValue = title[x-1];
    document.styleSheets[0].cssRules[0].style.visibility = y;
    document.getElementById('playid'+x).attributes[1].nodeValue = "play";
    document.styleSheets[1].cssRules[(x-1)].style.visibility = "visible";
  }
  if (y == 'hidden') {
    document.getElementById('movieTitles').firstChild.nodeValue = title[x-1];
    document.styleSheets[0].cssRules[0].style.visibility = y;
    document.getElementById('playid'+x).attributes[1].nodeValue = "#";
    document.styleSheets[1].cssRules[(x-1)].style.visibility = "hidden";
  }
}
</script>

</xsl:template>

<!-- #########################################End of style and scripts for robinsjexcal index########################################################-->

<!-- #########################################Start of HTML for robinsjexcal index########################################################-->

<xsl:template name="robinsjexcal-html">

<xsl:for-each select="library/category[@name='Title']/index">
  <xsl:choose>
    <xsl:when test="@name = '09'"><a href="Title_09_1.html" tvid="1" /></xsl:when>
    <xsl:when test="@name = 'A'"><a href="Title_A_1.html" tvid="2" /></xsl:when>
    <xsl:when test="@name = 'B'"><a href="Title_B_1.html" tvid="22" /></xsl:when>
    <xsl:when test="@name = 'C'"><a href="Title_C_1.html" tvid="222" /></xsl:when>
    <xsl:when test="@name = 'D'"><a href="Title_D_1.html" tvid="3" /></xsl:when>
    <xsl:when test="@name = 'E'"><a href="Title_E_1.html" tvid="33" /></xsl:when>
    <xsl:when test="@name = 'F'"><a href="Title_F_1.html" tvid="333" /></xsl:when>
    <xsl:when test="@name = 'G'"><a href="Title_G_1.html" tvid="4" /></xsl:when>
    <xsl:when test="@name = 'H'"><a href="Title_H_1.html" tvid="44" /></xsl:when>
    <xsl:when test="@name = 'I'"><a href="Title_I_1.html" tvid="444" /></xsl:when>
    <xsl:when test="@name = 'J'"><a href="Title_J_1.html" tvid="5" /></xsl:when>
    <xsl:when test="@name = 'K'"><a href="Title_K_1.html" tvid="55" /></xsl:when>
    <xsl:when test="@name = 'L'"><a href="Title_L_1.html" tvid="555" /></xsl:when>
    <xsl:when test="@name = 'M'"><a href="Title_M_1.html" tvid="6" /></xsl:when>
    <xsl:when test="@name = 'N'"><a href="Title_N_1.html" tvid="66" /></xsl:when>
    <xsl:when test="@name = 'O'"><a href="Title_O_1.html" tvid="666" /></xsl:when>
    <xsl:when test="@name = 'P'"><a href="Title_P_1.html" tvid="7" /></xsl:when>
    <xsl:when test="@name = 'Q'"><a href="Title_Q_1.html" tvid="77" /></xsl:when>
    <xsl:when test="@name = 'R'"><a href="Title_R_1.html" tvid="777" /></xsl:when>
    <xsl:when test="@name = 'S'"><a href="Title_S_1.html" tvid="7777" /></xsl:when>
    <xsl:when test="@name = 'T'"><a href="Title_T_1.html" tvid="8" /></xsl:when>
    <xsl:when test="@name = 'U'"><a href="Title_U_1.html" tvid="88" /></xsl:when>
    <xsl:when test="@name = 'V'"><a href="Title_V_1.html" tvid="888" /></xsl:when>
    <xsl:when test="@name = 'W'"><a href="Title_W_1.html" tvid="9" /></xsl:when>
    <xsl:when test="@name = 'X'"><a href="Title_X_1.html" tvid="99" /></xsl:when>
    <xsl:when test="@name = 'Y'"><a href="Title_Y_1.html" tvid="999" /></xsl:when>
    <xsl:when test="@name = 'Z'"><a href="Title_Z_1.html" tvid="9999" /></xsl:when>
    <xsl:otherwise><a href="blank" tvid="blank" /></xsl:otherwise>
  </xsl:choose>
</xsl:for-each>

<xsl:for-each select="library/category[@name='Other']/index">
  <xsl:choose>
    <xsl:when test="@name = 'All'"><a href="Other_All_1.html" tvid="255" /></xsl:when>
    <xsl:when test="@name = 'HD'"><a href="Other_HD_1.html" tvid="43" /></xsl:when>
    <xsl:when test="@name = 'TV Shows'"><a href="Other_TV Shows_1.html" tvid="887" /></xsl:when>
    <xsl:when test="@name = 'Movies'"><a href="Other_Movies_1.html" tvid="668" /></xsl:when>
    <xsl:when test="@name = 'Trailers'"><a href="Other_Trailers_1.html" tvid="872" /></xsl:when>
    <xsl:when test="@name = 'New'"><a href="Other_New_1.html" tvid="639" /></xsl:when>
    <xsl:when test="//index[@current='true']/@name = 'Top250'">
      <a href="Other_Top250_1.html" tvid="807" />
    </xsl:when>
    <xsl:otherwise><a href="blank" tvid="blank" /></xsl:otherwise>
  </xsl:choose>
</xsl:for-each>

<xsl:for-each select="library/category[@name='Genres']/index">
  <xsl:choose>
    <xsl:when test="@name = 'Action'"><a href="Genres_Action_1.html" tvid="228" /></xsl:when>
    <xsl:when test="@name = 'Animation'"><a href="Genres_Animation_1.html" tvid="264" /></xsl:when>
    <xsl:when test="@name = 'Comedy'"><a href="Genres_Comedy_1.html" tvid="266" /></xsl:when>
    <xsl:when test="@name = 'Documentary'"><a href="Genres_Documentary_1.html" tvid="362" /></xsl:when>
    <xsl:when test="@name = 'Drama'"><a href="Genres_Drama_1.html" tvid="372" /></xsl:when>
    <xsl:when test="@name = 'Fantasy'"><a href="Genres_Fantasy_1.html" tvid="326" /></xsl:when>
    <xsl:when test="@name = 'Other'"><a href="Genres_Other_1.html" tvid="684" /></xsl:when>
    <xsl:when test="@name = 'Sci-Fi'"><a href="Genres_Sci-Fi_1.html" tvid="724" /></xsl:when>
    <xsl:when test="@name = 'Thriller'"><a href="Genres_Thriller_1.html" tvid="847" /></xsl:when>
    <xsl:when test="@name = 'Reality'"><a href="Genres_Reality_1.html" tvid="732" /></xsl:when>
    <xsl:when test="@name = 'Horror'"><a href="Genres_Horror_1.html" tvid="467" /></xsl:when>
    <xsl:when test="@name = 'Family'"><a href="Genres_Family_1.html" tvid="3264" /></xsl:when>
    <xsl:when test="@name = 'Music'"><a href="Genres_Music_1.html" tvid="687" /></xsl:when>
    <xsl:otherwise><a href="blank" tvid="blank" /></xsl:otherwise>
  </xsl:choose>
</xsl:for-each>


<table class="main" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td class="moviespace">
      <table class="movies" align="center" valign="center" border="0">
        <xsl:for-each select="library/movies/movie[position() mod $nbCols = 1]">
          <tr>
            <xsl:apply-templates select=".|following-sibling::movie[position() &lt; $nbCols]">
              <xsl:with-param name="gap" select="(position() - 1) * $nbCols" />
              <xsl:with-param name="currentIndex" select="$currentIndex" />
              <xsl:with-param name="lastIndex" select="$lastIndex" />
              <xsl:with-param name="lastGap" select="($nbLines - 1) * $nbCols" />
            </xsl:apply-templates>
          </tr>
        </xsl:for-each>
      </table>
    </td>
  </tr>
  <tr>
    <td>
      <table id="titles" class="title" align="center" width="100%">
        <tr>
          <td class="blankrow" align="center" id="movieTitles">&#160;</td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td>
      <table align="center" class="navigation" border="0" background="{$index-navigation}" >
        <tr>
          <td align="center" valign="center" class="letters">
            <a href="#" onclick="return loadletter()" name="leters" class="sorting2" TVID="{$letters-sorting-TVID}">Letters</a>
          </td>
          <td align="center" valign="center" class="arrows" rowspan="2">
            <a href="#" onclick="return upDown(-1)" name="left" onkeyrightset="middle" id="up" TVID="{$left-arrow-TVID}"><img src="{$left-arrow-unselected}" onfocussrc="{$left-arrow-selected}"/></a>
          </td>
          <td align="center" class="smallsort" rowspan="2">
            <a href="." class="sorting" id="twoup">&#160;</a>
          </td>
          <td align="center" class="smallsort" rowspan="2">
            <a href="." class="sorting" id="previ">&#160;</a>
          </td>
          <td align="center" class="bigsort" rowspan="2">
            <a href="Other_All_1.html" class="mainsorting" name="middle" onkeyleftset="left" onkeyrightset="right" id="change">All</a>
          </td>
          <td align="center" class="smallsort" rowspan="2">
            <a href="Other_HD_1.html" class="sorting" id="next">HD</a>
          </td>
          <td align="center" class="smallsort" rowspan="2">
            <a href="Other_Movies_1.html" class="sorting" id="twodown">Movies</a>
          </td>
          <td align="center" valign="center" class="arrows" rowspan="2">
            <a href="#" onclick="return upDown(1)" name="right" onkeyleftset="middle" id="down" TVID="{$right-arrow-TVID}"><img src="{$right-arrow-unselected}" onfocussrc="{$right-arrow-selected}"/></a>
          </td>
          <td valign="center" align="center" class="updown">
            <xsl:choose>
              <xsl:when test="$currentIndex = 1">
                <img src="pictures/blank75x30.png" />
              </xsl:when>
              <xsl:otherwise>
                <a name="pgup" tvid="{$page-up-TVID}" class="sorting2" onfocus="togglePopup(2)" onblur="togglePopup(2)">
                  <xsl:attribute name="href"><xsl:value-of select="//index[@current='true']/@previous"/>.html</xsl:attribute>Up</a>
              </xsl:otherwise>
            </xsl:choose>
          </td>
        </tr>
        <tr>
          <td align="center" valign="center" class="genres">
            <a href="#" onclick="return loadgenre()" class="sorting2" TVID="{$genres-sorting-TVID}">Genre</a>
          </td>
          <td valign="center" align="center" class="updown">
            <xsl:choose>
              <xsl:when test="$currentIndex = $lastIndex">
                <img src="pictures/blank75x30.png" />
              </xsl:when>
              <xsl:otherwise>
                <a name="pgdn" tvid="{$page-down-TVID}" class="sorting2" onfocus="togglePopup(2)" onblur="togglePopup(2)" >
                  <xsl:attribute name="href"><xsl:value-of select="//index[@current='true']/@next" />.html</xsl:attribute>Down</a>
              </xsl:otherwise>
            </xsl:choose>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<div class="counter" name="title99">
  <xsl:value-of select="$currentIndex" /> / <xsl:value-of select="$lastIndex" />
</div>
<xsl:for-each select="library/movies/movie">
  <xsl:if test="$zoomPoster='true'">
    <img class="bigthumb">
      <xsl:attribute name="id">bigthumb<xsl:value-of select="position()" /></xsl:attribute>
      <xsl:attribute name="src"><xsl:value-of select="detailPosterFile" /></xsl:attribute>
    </img>
  </xsl:if>
</xsl:for-each>
</body>
</html>
</xsl:template>

<xsl:template match="movie">
  <xsl:param name="gap" />
  <xsl:param name="currentIndex" />
  <xsl:param name="lastIndex" />
  <xsl:param name="lastGap" />

  <td>
    <a>
      <xsl:attribute name="href"><xsl:value-of select="details" /></xsl:attribute>
      <xsl:attribute name="onfocus">titles(<xsl:value-of select="position()+$gap" />,'visible');</xsl:attribute>
      <xsl:attribute name="onblur">titles(<xsl:value-of select="position()+$gap" />,'hidden');</xsl:attribute>
      <xsl:attribute name="id">movies<xsl:value-of select="position()+$gap" /></xsl:attribute>

      <xsl:if test="$lastIndex != 1">
        <xsl:if test="$gap=0 and $currentIndex != 1">
          <xsl:attribute name="onkeyupset">pgup</xsl:attribute>
        </xsl:if>
        <xsl:if test="$mcounts &lt; 8">
          <xsl:attribute name="onkeydownset">middle</xsl:attribute>
        </xsl:if>
        <xsl:if test="$gap=$lastGap and $currentIndex != $lastIndex">
          <xsl:attribute name="onkeydownset">middle</xsl:attribute>
        </xsl:if>
        <xsl:if test="position()+$gap = 1">
          <xsl:attribute name="name">firstone</xsl:attribute>
          <xsl:attribute name="onkeyleftset">seven</xsl:attribute>
        </xsl:if>
        <xsl:if test="position()+$gap = 7">
          <xsl:attribute name="name">seven</xsl:attribute>
          <xsl:attribute name="onkeyrightset">eight</xsl:attribute>
        </xsl:if>
        <xsl:if test="position()+$gap = 8">
          <xsl:attribute name="name">eight</xsl:attribute>
          <xsl:attribute name="onkeyleftset">seven</xsl:attribute>
        </xsl:if>
        <xsl:if test="position()+$gap = 14">
          <xsl:attribute name="name">fourteen</xsl:attribute>
          <xsl:attribute name="onkeyrightset">firstone</xsl:attribute>
        </xsl:if>
      </xsl:if>
      <img>
        <xsl:attribute name="src"><xsl:value-of select="thumbnail" /></xsl:attribute>
        <xsl:attribute name="onmouseover">titles(<xsl:value-of select="position()+$gap" />,'visible');</xsl:attribute>
        <xsl:attribute name="onmouseout">titles(<xsl:value-of select="position()+$gap" />,'hidden');</xsl:attribute>
        <xsl:attribute name="id">image<xsl:value-of select="position()+$gap" /></xsl:attribute>
        <xsl:choose>
          <xsl:when test="$zoomPoster='true'">
            <xsl:attribute name="width"><xsl:value-of select="$smallPosterWidth" /></xsl:attribute>
            <xsl:attribute name="height"><xsl:value-of select="$finalSmallPosterHeight" /></xsl:attribute>
            <xsl:attribute name="border">0</xsl:attribute>
            <xsl:attribute name="onfocussrc">pictures/tran.png</xsl:attribute>
          </xsl:when>
          <xsl:otherwise>
            <xsl:attribute name="onfocussrc">pictures/detailed3.png</xsl:attribute>
          </xsl:otherwise>
        </xsl:choose>
      </img>
    </a>
    <xsl:choose>
      <xsl:when test="count(files/file) > 2 or (season > 0 and count(files/file) > 1)">
        <a>
          <xsl:attribute name="href"><xsl:value-of select="baseFilename" />.playlist.jsp</xsl:attribute>
          <xsl:attribute name="tvid">#</xsl:attribute>
          <xsl:attribute name="id">playid<xsl:value-of select="position()+$gap" /></xsl:attribute> 
          <xsl:attribute name="vod">playlist</xsl:attribute>
        </a>
      </xsl:when>
      <xsl:otherwise>
        <xsl:variable name="ext" select="substring(files/file[1]/fileURL, string-length(files/file[1]/fileURL)-3, 4)" />
        <a>
          <xsl:attribute name="href"><xsl:value-of select="files/file[1]/fileURL" /></xsl:attribute>
          <xsl:attribute name="tvid">#</xsl:attribute>
          <xsl:attribute name="id">playid<xsl:value-of select="position()+$gap" /></xsl:attribute> 

          <xsl:if test="//movie/container = 'ISO' or $ext = '.ISO' or $ext = '.iso'
                or //movie/container = 'IMG' or $ext = '.IMG' or $ext = '.img'
                or //movie/container = 'MDF' or $ext = '.MDF' or $ext = '.mdf'
                or //movie/container = 'BIN' or $ext = '.BIN' or $ext = '.bin'
                or //movie/container = 'NRG' or $ext = '.NRG' or $ext = '.nrg'
                or substring(files/file/fileURL,string-length(files/file[1]/fileURL)-7,8) = 'VIDEO_TS'">
            <xsl:attribute name="zcd">2</xsl:attribute> 
          </xsl:if>

          <xsl:attribute name="vod" />
        </a>
      </xsl:otherwise>
    </xsl:choose>

  </td>
</xsl:template>

<xsl:template match="movie" mode="bigthumbcss" >
  <xsl:param name="gap" />

  <!-- tableTop sets the number of pixels down where the first row of nonzoomed posters starts -->
  <xsl:variable name="tableTop">41</xsl:variable>

  <!-- lastRowUpTweak moves the last row of zoomed posters up by the number of pixels set, to better show the title -->
  <xsl:variable name="lastRowUpTweak">16</xsl:variable>

  <xsl:variable name="zoomPosterWidth">
    <xsl:value-of select="round( $smallPosterWidth * $zoomFactor )" />
  </xsl:variable>
  <xsl:variable name="zoomPosterHeight">
    <xsl:value-of select="round( $finalSmallPosterHeight * $zoomFactor )" />
  </xsl:variable>
  <xsl:variable name="zoomPosterHeightDifference">
    <xsl:value-of select="$zoomPosterHeight - $finalSmallPosterHeight" />
  </xsl:variable>

  <xsl:variable name="tweak">
    <xsl:choose>
      <xsl:when test="($nbLines - 1) = ($gap div $nbCols) and $gap != 0">
        <xsl:value-of select="- $lastRowUpTweak" />
      </xsl:when>
      <xsl:otherwise>0</xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

  <xsl:variable name="top">
    <xsl:value-of select="$tableTop + (($gap div $nbCols) * ($finalSmallPosterHeight + 2) + 2) - ($zoomPosterHeightDifference div 2) + $tweak" />
  </xsl:variable>

  <xsl:variable name="left">
    <xsl:value-of select="(position() - 1) * $smallPosterWidth + (position() * 2) - (($zoomPosterWidth - $smallPosterWidth) div 2)" />
  </xsl:variable>

  #bigthumb<xsl:value-of select="position()+$gap"/>  { position:absolute; visibility:hidden; width:<xsl:value-of select="$zoomPosterWidth" />; top:<xsl:choose><xsl:when test="$top &gt; 0"><xsl:value-of select="$top" /></xsl:when><xsl:otherwise>1</xsl:otherwise></xsl:choose>; left:<xsl:value-of select="$left" /> }

</xsl:template>

</xsl:stylesheet>
